/*
 * @Description  : 浏览记录
 * @Author       : zhao
 * @Date         : 2022-07-22 18:57:09
 * @LastEditors  : zhao
 * @LastEditTime : 2022-07-25 09:52:36
 */



import { Message } from "element-ui"
import { AddSearchRecord, GetSearchRecord, DeleteBrowsingRecordAll, DeleteBrowsingRecord } from '@/api/SearchRecord'

const state = {

    isOpen: false, //

}

const mutations = {

}

const actions = {

    addSearchRecord({ dispatch, rootState, state }, data) {
        return new Promise((resolve, reject) => {
            AddSearchRecord(data).then(res => {
                if (res.code === 200) {

                    resolve(res)
                }

            }).catch(err => {
                reject(err)
            })
        })

    },
    getSearchRecord({ dispatch, rootState, state }, data) {
        return new Promise((resolve, reject) => {
            GetSearchRecord(data).then(res => {
                if (res.code === 200) {

                    resolve(res)
                }

            }).catch(err => {
                reject(err)
            })
        })

    },
    deleteBrowsingRecordAll({ dispatch, rootState, state }, data) {
        return new Promise((resolve, reject) => {
            DeleteBrowsingRecordAll(data).then(res => {
                if (res.code === 200) {
                    Message.success(res.msg || "删除成功")

                    resolve(res)
                }

            }).catch(err => {
                reject(err)
            })
        })

    },
    deleteBrowsingRecord({ dispatch, rootState, state }, data) {
        return new Promise((resolve, reject) => {
            DeleteBrowsingRecord(data).then(res => {
                if (res.code === 200) {
                    Message.success(res.msg || "删除成功")
                    resolve(res)
                }

            }).catch(err => {
                reject(err)
            })
        })

    },

}
const getters = {

}
export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
}